<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title></title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  
    {include file="public/css"}
    {include file="public/js"}
</head>
<body>

<!-- 后台面包屑导航 -->
{:get_admin_breadcrumb()}


<!-- 搜索表单 -->
{:create_search_form("添加广告位置",$keywordsData,$customSingleField,$groupData,$dateData,$orderData)}

<div class="layui-form">
  <table class="layui-table" id="demo">
    <colgroup>
      <col width="50">
      <col width="100">
      <col width="100">
      <col width="310">
      <col width="130">
      <col width="50">
      <col width="120">
      <col width="80">
      <col width="330">
    </colgroup>
    <thead>

      <tr>
        <th><input type="checkbox"  id="selectAll"  lay-skin="primary" lay-filter="selectAll"></th>
        <th>广告位ID</th>
        <th>类型</th>
        <th>名称</th> 
        <th>宽度*高度</th>
       
        <th>广告数量</th>
         <th>HTML调用代码</th>
        <th>状态</th>
        <th>操作</th>
      </tr> 
    </thead>
    <tbody>

{volist name='list' id='vo'}
      <tr>
        <td><input type="checkbox" name="position_id[]" class="id " title=""  lay-skin="primary" value="{$vo.position_id}"></td>
        <td>{$vo.position_id}</td>
        <td>{if $vo.position_type ==0 }图片广告{elseif $vo.position_type ==1}代码广告{elseif $vo.position_type ==2}幻灯片广告{else}{/if}</td>
        <td>{$vo.position_name}</td>

        <td>{$vo.position_width?$vo.position_width:'自动'} * {$vo.position_height?$vo.position_height:自动}</td>


        <td> <a href="javascript:;" onclick="edit('{:url("ad/index",["position_id"=>$vo["position_id"]])}','管理广告【{$vo["position_name"]}】')">{$vo.ad_num}</a></td>

        <td><input name="" class="layui-input" readonly value="{:ad({$vo.position_id})}"></td>

        <td>{if $vo.status ==1}<span class="layui-badge layui-bg-blue">开启</span>{else}<span class="layui-badge">关闭</span>{/if}</td>
        <td>

        <div class="layui-btn-group">
         <button title="添加广告" class="layui-btn layui-btn-sm layui-btn-normal" id="edit" 
         onclick="add('{:url("ad/add",["position_id"=>$vo["position_id"]])}','添加广告【{$vo["position_name"]}】')" > 
         <i class="layui-icon">&#xe654;</i>添加广告
         </button>
    <button class="layui-btn layui-btn-sm layui-btn-normal" id="edit" title="管理广告" 
    onclick="edit('{:url("ad/index",["position_id"=>$vo["position_id"]])}','管理广告【{$vo["position_name"]}】')"  > <i class="fa fa-eye" aria-hidden="true"></i> 管理广告</button>

          <button class="layui-btn layui-btn-sm layui-btn-normal" id="edit" onclick="edit('{:url("adPosition/edit",["position_id"=>$vo["position_id"]])}','编辑广告位')"> <i class="layui-icon"  title="编辑广告位">&#xe642;</i></button>

          <button class="layui-btn layui-btn-sm layui-btn-primary"  onclick="del('{:url("adPosition/del",["position_id"=>$vo["position_id"]])}')"> <i class="layui-icon">&#xe640;</i></button>
         </div>
 </td>
      </tr>
{/volist}

    </tbody>
  </table>


</div>

<div id="pages">{$page|raw}</div>


<div class="layui-btn-group demoTable">

  <button class="layui-btn layui-btn-primary" id="del" data-type="getCheckData"> <i class="layui-icon">&#xe640;</i> 批量删除</button>
</div>


<script>
$(function(){
  //全选批量删除
        var id = [];
        var url ="{:url('adPosition/del')}"; //请求的url
        var data = {"position_id":id};   //传递的表单数据
        var delButton = "#del"; //删除节点class 或者ID
        var checkboxClass = ".id"; //多选框class

         $(delButton).click(function(){
              $(checkboxClass).each(function() {
              if(this.checked == true){
                   id.push($(this).val()); 
              }
              });              
         if(id.length == 0){
            parent.layer.alert('你没有选中任何分类',{title:'批量删除提示'});
         }else{
                     var index = parent.layer.confirm('批量删除后，数据不可恢复', {
                      btn: ['确定删除','取消'] //按钮
                      ,title:'是否批量删除'
                      ,shadeClose:true
                      ,icon: 3
                      ,anim: 5  //动画类型
                    }, function(){
                        parent.layer.close(index);
                    // 确定ajax 删除数据
                                $.post(url,data        
                                     ,function(json){
                                      if(json.code == 0){
                                          layer.msg(json.msg);
                                               setTimeout(function(){ 
                                                     window.location.reload();  //页面刷新
                                                },1000);
                                           }
                                         }
                                       );

                    }, function(){
                       // 取消

                    });

         }

    });
$("#add").on("click",function(){
  blank('{:url("adPosition/add")}','添加广告位','580px','80%');
});

});

</script>
</body>

</html>